package com.woniuxy.order.controller;


import com.woniu.zsd.commons.core.model.Result;
import com.woniuxy.order.entity.Statistics;
import com.woniuxy.order.service.IStatisticsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author author
 * @since 2025-05-13
 */
@RestController
@RequestMapping("/statistics")
@Api(tags = "统计管理")
public class StatisticsController {

    @Resource
    private IStatisticsService statisticsService;

    /**
     * 根据月份查询统计数据
     * @param month 月份，格式为yyyy-MM
     * @return 统计结果
     */
    @GetMapping("/byMonth")
    @ApiOperation("根据月份查询统计数据")
    public Result<List<Statistics>> getStatisticsByMonth(@RequestParam String month)throws Exception {
        List<Statistics> statistics = statisticsService.getStatisticsByMonth(month);
        return Result.getListResult(Statistics.class)
                .setData(statistics)
                .setMsg("查询成功")
                .setCode(200);
    }

}
